class Solution {//leetcode35——搜索插入位置
public:
    int searchInsert(vector<int>& nums, int target) {
        int left=0,right=nums.size()-1;
        while(left<right){
            int mid=(right-left+1)/2+left;
            if(nums[mid]<=target)left=mid;
            else right=mid-1;
        }
        if(target<=nums[left])return left;
        return left+1;
    }
};